#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    //设置范围
    ui->horizontalSlider->setMinimum(100);
    ui->horizontalSlider->setMaximum(2000);
    ui->verticalSlider->setMinimum(100);
    ui->verticalSlider->setMaximum(2000);

    //必须设置，否则设置完范围就会自动更改未知数值
    ui->horizontalSlider->setValue(800);
    ui->verticalSlider->setValue(800);

    //设置方向键的步长
    ui->horizontalSlider->setSingleStep(50);
    ui->verticalSlider->setSingleStep(50);
}

Widget::~Widget()
{
    delete ui;
}
void Widget::on_horizontalSlider_valueChanged(int value)
{
    //获取窗口的尺寸
     const QRect& rec=this->geometry();
     //只修改宽度
     this->setGeometry(rec.x(),rec.y(),value,rec.height());
}

void Widget::on_verticalSlider_valueChanged(int value)
{
    const QRect& rec=this->geometry();
    //只修改高度
    this->setGeometry(rec.x(),rec.y(),rec.width(),value);
}
